package com.ems.mapper;

import com.ems.entity.BatteryStatisticsDayEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ems.vo.BatteryStatisticsDayVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * BMS数据备份表，每日凌晨备份前一天数据 Mapper 接口
 * </p>
 *
 * @author WuZH
 * @since 2024-05-07
 */
@Mapper
public interface BatteryStatisticsDayMapper extends BaseMapper<BatteryStatisticsDayEntity> {

    @Select ( value = "<script>SELECT * FROM battery_statistics_day_info\n" +
            "<trim prefix=\"WHERE\" prefixOverrides=\"and | or\">" +
            "<if test='batteryStatisticsDayVo.startTime!=null'> AND DATE_FORMAT(dataTime, '%Y-%m-%d') &gt;= DATE_FORMAT(#{batteryStatisticsDayVo.startTime}, '%Y-%m-%d')</if>" +
            "<if test='batteryStatisticsDayVo.endTime!=null'> AND DATE_FORMAT(dataTime, '%Y-%m-%d') &lt;= DATE_FORMAT(#{batteryStatisticsDayVo.endTime}, '%Y-%m-%d')</if>" +
            "<if test='batteryStatisticsDayVo.stationId!=null'> AND stationId=#{batteryStatisticsDayVo.stationId}</if>" +
            "</trim></script>")
    List<BatteryStatisticsDayVo> queryList ( @Param ( "batteryStatisticsDayVo" ) BatteryStatisticsDayVo batteryStatisticsDayVo );

}
